import os
import numpy as np
from numpy.core.multiarray import result_type
'''
按照pos：part：neg = 1： 2： 1的比例生成dataset
'''


# 24_94
def comb_24_94():

    save_dir = "./24_94/"

    f1 = open(os.path.join(save_dir, 'pos_24_94.txt'), 'r')  # 对应的样本的文档建立
    f2 = open(os.path.join(save_dir, 'neg_24_94.txt'), 'r')
    f3 = open(os.path.join(save_dir, 'part_24_94.txt'), 'r')
    result = open(os.path.join(save_dir, 'image_24_94.txt'), 'w')   # 寫入結果

    pos = np.random.permutation(f1.readlines())[:5000]
    part = np.random.permutation(f3.readlines())[:10000]
    neg = np.random.permutation(f2.readlines())[:5000]

    for i in pos:
        result.write(i)
    for i in part:
        result.write(i)
    for i in neg:
        result.write(i)

    f1.close()
    f2.close()
    f2.close()
    result.close()

def comb_12_47():

    save_dir = "./12_47/"

    f1 = open(os.path.join(save_dir, 'pos_12_47.txt'), 'r')  # 对应的样本的文档建立
    f2 = open(os.path.join(save_dir, 'neg_12_47.txt'), 'r')
    f3 = open(os.path.join(save_dir, 'part_12_47.txt'), 'r')
    result = open(os.path.join(save_dir, 'image_12_47.txt'), 'w')   # 寫入結果

    pos = np.random.permutation(f1.readlines())[:5000]
    part = np.random.permutation(f3.readlines())[:10000]
    neg = np.random.permutation(f2.readlines())[:5000]

    for i in pos:
        result.write(i)
    for i in part:
        result.write(i)
    for i in neg:
        result.write(i)

    f1.close()
    f2.close()
    f2.close()
    result.close()

if __name__ == '__main__':
    comb_12_47()